package com.cn.gz.liwy.datatype;

import com.cn.gz.liwy.constan.StaticFinal;
import sun.awt.geom.AreaOp;

public class MyBoolean extends DataTypeBase implements DataType{

    private  boolean  boolean1;

    private  Boolean aBoolean;

    public MyBoolean(){
        setTypeName("boolean");
        setTypeSize(size());
        setTypeValueRange(valueRange());
        // byte转换为字符串  方法1
        setTypeDefaultVal(defaultValue());
        setTypePacketClass(packetClass());
        new MyBoolean(this);
        out("============"+getTypeName()+"类型使用规则"+"============");
        commonlyUsed();
        illegalUsed();
        out("==================华丽丽的分割线==================");
    }

    public MyBoolean (MyBoolean MyBoolean){
//        将初始好的子类以参数的形式传到父类有参构造
        super(MyBoolean);
    }

    @Override
    public int size() {
        return 8;
    }

    @Override
    public String valueRange() {
        return "true"+"/"+"false"+"/null";
    }

    @Override
    public String defaultValue(){
        String dfStr = "，而它的包装类默认值是：";
        return boolean1+dfStr+String.valueOf(aBoolean);
    }

    @Override
    public void commonlyUsed() {
        int i = 9;
        int j = -100;
        boolean1 = i>j;
        if(boolean1){
            out(StaticFinal.RIGHT+"判断正确 9 大于 -100");
        }
        boolean1 = false;
        if(!boolean1){
            out(StaticFinal.RIGHT+"用于逻辑【或|】【与&】【非&】");
            out("&& 与 & 区别：如果 a 为 false，则不计算 b（因为不论 b 为何值，结果都为 false）");
            out("|| 与 | 区别：如果 a 为 true，则不计算 b（因为不论 b 为何值，结果都为 true）");
            out("用于逻辑【或|】【与&】【与&】");
        }
    }

    @Override
    public void illegalUsed() {
        out(StaticFinal.ERROR + "boolean变量被赋值为0或1之外的数字");

        //举例如下
        //boolean b =2;
    }

    @Override
    public String packetClass() {
        return ""+Boolean.class;
    }

    public void setBoolean1(boolean b){
        this.boolean1 = b;
    }

    public boolean getBoolean1(){
        return this.boolean1;
    }

    public Boolean getaBoolean() {
        return aBoolean;
    }

    public void setaBoolean(Boolean aBoolean) {
        this.aBoolean = aBoolean;
    }
}
